import   { aria } from "../aria/index"
const { AriaEntity } = aria;


class Entity {
    private static instance: Entity | null = null
    public RPC: any | null = null
    private  constructor() {}
    static async getInstance() :Entity {
        if(!Entity.instance){
            Entity.instance = new Entity()
            Entity.instance.RPC = await AriaEntity()
        } 
        return Entity.instance
    }

    public async performOperation(): Promise<any> {
        // 执行某些操作
        // console.log("执行某些操作", this.RPC.existAria())
        console.log("this.RPC", this.RPC)
        const rpc = await this.RPC
        rpc.existAria();
        rpc.testInfo();
    }
}


// 工厂类
export class EntityFactory {
    static createEntiry(): Entity {
        const entity = Entity.getInstance();
        return entity;
    }
}



// 使用实体的其他方法
export function  entityMethods() {
    const entity = EntityFactory.createEntiry();
    entity.performOperation()
}




// magnet 下载
export function  DownMagnetFile(){
    const magnet =
    "magnet:?xt=urn:btih:88594AAACBDE40EF3E2510C47374EC0AA396C08E&dn=bbb_sunflower_1080p_30fps_normal.mp4&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.publicbt.com%3a80%2fannounce&ws=http%3a%2f%2fdistribution.bbb3d.renderfarming.net%2fvideo%2fmp4%2fbbb_sunflower_1080p_30fps_normal.mp4";
    ipcMain.handle('manage', async (event, ...args) => {
      this.MAGNET.download("addUri", magnet)
    })
}